package controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import model.User;
import service.UserService;

@RestController
public class TestController {
	
	@Autowired
	private UserService userService;
	
	@ResponseBody
	@RequestMapping("/hello")
	public String hello() 
	{
		return "success";
	}
	
	@RequestMapping("/test1")
	public ModelAndView test1(ModelAndView mv)
	{
		int i = 1 / 0;
		mv.setViewName("NewFile.html");
		return mv;
	}
	
	@RequestMapping("/test2")
	public String test2() {
		return "index";
	}
	
	
	@RequestMapping("/test3")
	public String test3() {
		User user = new User();
		user.setUsername("test");
		user.setAddTime(new Date());
		user.setPassword("123456");
		user.setSex(0);
		user.setAlias("test123");
		userService.saveUser(user);
		return "qqTalk";
	}
	
	
	/*public static void main(String[] args) {
		SpringApplication.run(TestController.class, args)
	}
	*/
}
